How to Develop an Online Shopping Cart (Part Two)
Table of Contents
Security and Liability—Protect Your Customer's Data and Yourself
There are serious issues to consider when it comes to data security. Even capturing someone's credit card data temporarily is a risk. Storing it in your database is even a bigger one. The merchant and the developer have a responsibility to show "Due Diligence" in regard to security. Due to the increasing concern about identity theft, you must take necessary precautions to protect your customers' personal and credit information. Let's look at some security measures that your app must take into consideration. Here are a few points to consider.
- Protect customer credit card data.
- Secure your database.
- Protect data in transit with an SSL (Secure Socket Layer) certificate An SSL encrypts your pages and accompanying data when your browser requests it. It will only be unencrypted and viewable by the same browser that requested it. If anyone along the way should intercept the data packets, the data will be unusable.
Secure Socket Layer (SSL)
First, Let's Look at SSLs. There are two primary options when it comes to setting up SSL security for your e–commerce website: Shared SSL and Individual SSL, Which Is Better? Let's take a look at the options and weigh the merits of each.
Some Internet Service Providers (ISP) will make a Shared SSL available to their customers. The ISP shares its SSL with you by placing your secure pages on its SSL protected server.
Advantages:
- Cheaper and sometimes free.
- For the most part, a shared SSL is as secure as an individual SSL.
- Easy to set up—the ISP already has it set up. They just internally map part of your site through their SSL server.
Disadvantages:
- You aren't listed as the SSL certificate owner. This can potentially shake consumer confidence and loose sales.
- Cannot be transferred if you move to a different host.
- Incompatibility with many shopping carts. Since shared SSL requires a transfer to or through a separate server, many session-based carts will not work.
Your other choice is to purchase our own individual SSL certificate. When you purchase your own SSL certificate, the issuing company generates a unique SSL code or key. You must send this code exactly as is to your ISP to be set up on your site. It is set up and mapped to your site's IP address.
Advantages:
- The SSL is registered to your company. If a user checks the certificate, you appear as the owner. This bolsters consumer confidence.
- If you change ISPs, you take your SSL with you.
- The SSL is installed on your site. No server transfer or switching required. This avoids session problems.
Disadvantages:
- Individual SSLs cost more. They are not nearly as costly as they used to be though. You can purchase an SSL for under US$100 a year.
- More is involved in setting it up, although knowledgeable ISPs make the process quite painless.
Over the last year or so, the cost of acquiring your own SSL has become much more reasonable. It has become a much less involved process as well. With the added consumer confidence an individual SSL provides, it really makes this the wise choice.
Database Security
With an SSL certificate, now your data is safe while it's moving around. But, what about when it's in your database? Is it secret? Is it safe? Evil is looking for your data. Identity theft and malicious mischief are very wide spread on the web. I've talked about securing your data in–transit. Now I'll talk about making sure it's safe in your database.
The most secure data is data you don't have. Think carefully about what to store in your database. The less sensitive the data you have in your site's database about you, your business, and your customers, the better.
Should you store credit data in your database? For example, if you are using an on-line payment processor, do you really need to store your customer's credit card data? If you store it, you are responsible for what happens to it. Why not just let the payment processor worry about that? I talk about data processors later in the article. If you store it, you need to think about securing it not only from the web, but internally as well. Most credit card theft is done by employees of the company acquiring the credit card information. Take care to keep the data secure at all levels—internally and externally.
What about company accounting data? Once again, it would be better to store this in a database that has no online access. It's better to keep this separate from your online data and then just synch the two data sources. Now, I'll talk about securing your database by hiding it and making it hard to get to.
Basic Steps To Secure Your Database
There have been many books written on the subject of database security. There's no way I can cover it all here, so I will just touch on the basics for now. It will be worth your while to become very familiar with the security options available to your database of choice before your site goes live.
-
Put file databases, such as Microsoft Access, above the root of your site. If this option is not available, have your ISP set the permissions of a folder in your web site as non-browsable. This will prevent anyone from browsing to your database file and downloading it.
Figure 1. Place file databases outside the root of your website.
-
Set permissions on your database and use usernames and passwords in your queries. Here is an example of a ColdFusion query that uses a username and password.
<cfquery name="RecordsetName" datasource="YourDSN" username="YourUsername" password="YourPassword"" > SELECT * FROM TableName </cfquery>
Doing this makes it much more difficult for someone to try to guess what your datasource access information is and attempt to query your database.
-
Don't pass actual database table or field names in query strings.
http://www.yoursite.com/pagename.cfm?MyID=1234
In this example, the actual database field name for
MyIDshould not beMyID. If someone should figure out your data source name (DSN), there is no use giving them the field names too. If a malicious person can get a hold of your database column names, he can manipulate and even delete your database. If you are using ColdFusion as your application server platform, consider using thecfqueryparamtag to avoid SQL injection hacks. See Dave Watt's article on Securing Database Access Using the cfqueryparam Tag for more information on this. -
Dynamically populate your Data Source Name (DSN). Populate your DSN in your Application.cfm (ColdFusion), Global.asa (ASP), or in and include (PHP). Then, call the DSN dynamically in your queries. While you're at it, you can also set your DSN username and password and call them dynamically as well. Here is an example of how to do this in a ColdFusion application.
Set the variables in your
Application.cfm.<cfset request.MyDSN="ActualDSN"> <cfset request.MyUsername="ActualUsername"> <cfset request.MyPassword="ActualMyPassword >
Call the variables in your queries.
<cfquery name="RecordsetName" datasource="<cfoutput>#request.MyDSN#</cfoutput>" username="<cfoutput>#request.MyUsername#</cfoutput>" password=" cfoutput>#request.MyPassword#</cfoutput>" > SELECT * FROM TableName </cfquery>This has several advantages First of all, you are not including this confidential data and repeating it in every query throughout your application. If fact, you can even place the code that creates these variable in an include file or a custom tag that you store in a secure folder. Then, call the include or custom tag from the Application.cfm file.
Secondly, this makes your site maintenance much easier because it allows you to globally change your DSN, username, and password in one easy place. If you feel your DSN has been compromised, you can change it in seconds.
These are just a few general tips about security. Again you should take the time to see what security features your database has and take advantage of them. Also, take time to review the content on the Security Developer Center, and Ray West's article, Writing Secure Dreamweaver MX Applications.
Now that the shopping cart is safe and secure, let's see about getting the money.